<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
if(isset($_SESSION['lang']))
    require_once "./language_files/reviewProcessI_" . $_SESSION['lang'] . ".php";
else
    require_once "./language_files/reviewProcessI_en.php";
?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta http-equiv="X-UA-Compatible" content="IE=9" />    
        <link href="style3.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <form id="form" name="form" method="post" action="">
            <?php
            require_once "functions.php";
			$cID = intval($_GET['conference_id']);
            $confid = mysql_real_escape_string($cID);
			$pID = intval($_GET['paper_id']);
            $paperid = mysql_real_escape_string($pID);
            $member_id=$_SESSION['member_id'];
			
			$cName = get_conference_name($confid);
            $confName=formatText_safe($cName);
            print "<h1>{$confName}</h1>";
			$pTitle = get_paper_title($paperid);
            $paperTitle = formatText_safe($pTitle);
            print "<h1>{$paperTitle}</h1>";
            echo $lang['choose'];
            ?>
            <br/> <input id="in1" type="radio" name="rev[]" value= "online"/><label for="in1"><?php echo $lang['online'];?></label><br/>
            <input id="offline" type="radio" name="rev[]" value= "offline"/><label for="offline"><?php echo $lang['offline'];?></label>
            <br/>
            <input id="go" type="submit" name="go" value="<?php echo $lang['go'];?>" onclick="check()"/>
            <?php
//directing to the DownloadFor review page.
            if(isset($_POST['down']))
            {
				$I = mysql_real_escape_string($_GET['id']); 
                header("Location: DownloadForReview.php?id={$I}");
            }
            ?>
        </form>
        <input type ="hidden" id="paper" name ="paper" value="<?php echo mysql_real_escape_string($_GET['paper_id']);?>"/>
        <input type ="hidden" id="version" name ="version" value="<?php $pid = mysql_real_escape_string($_GET['paper_id']); echo get_latest_version($pid);?>"/>
        <input type ="hidden" id="conf" name ="conf" value="<?php echo mysql_real_escape_string($_GET['conference_id']);?>"/>
        <input type="hidden" id="deadline" name="deadline" value="
               <?php
               include 'statics.php';
               $rsResult=rsSelect("*","conference",array('conference_id=',$confid,'AND','rev_endDate>','E__NOW()'));
               if(mysql_num_rows($rsResult) === 0)
                   echo $lang['t'];
               else
                   echo $lang['f'];
               ?>"/>
               <?php include "jquery.php";?>
        <script type="text/javascript">
            //<![CDATA[
            function check() {
                if (document.getElementById("in1").checked==true && document.getElementById('deadline').value.indexOf("true")!=-1) {
                    document.getElementById("form").target="_blank";
                    document.getElementById("form").action = "startReview.php?version_id="+document.getElementById("version").value+"&conference_id=" +document.getElementById("conf").value;
                    //"startReview.php?id="+document.getElementById("paper").value+"&confid=" +document.getElementById("conf").value;
                    //window.location = "startReview.php?id="+document.getElementById("paper").value+"&confid=" +document.getElementById("conf").value;
                }  
                else if(document.getElementById("in1").checked==true && document.getElementById('deadline').value.indexOf("true")==-1)
                {
                    alert('Deadline for reviews is already past');
                    document.getElementById('form').action="";
                }
                // directing to the downloadForReview page with the variables needed to download the pdf
                if (document.getElementById("offline").checked && document.getElementById('deadline').value.indexOf("true")!=-1) {
                    document.form.action = "DownloadForReview.php?id="+document.getElementById("paper").value+"&confid="+document.getElementById("conf").value+"&verid="+document.getElementById("version").value;
                } 
                else if(document.getElementById("offline").checked && document.getElementById('deadline').value.indexOf("true")==-1)
                {
                    alert('Deadline for reviews is already past');
                    document.getElementById('form').action="";
                }
            }
            //]]>
        </script>
        <script type="text/javascript">
            //<![CDATA[
            $('#go').click (function(){
                if (document.getElementById("offline").checked || document.getElementById("in1").checked) {
               
                } 
                else {
                    alert ('no button checked');
                }
            });
            //]]>
        </script>
    </body>
</html>